package com.af.monitorModule.timmer;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

@Component
public class RedisArrange {

    @Autowired
    private RedisTemplate<String, Object> redisTemplate;

    private static final Logger logger = LoggerFactory.getLogger(RedisArrange.class);

    /**
     * 每日零点做的
     */
    @Scheduled(cron = "0 0 0 * * ? ")
    public void cleanDaySend(){
        //清空信息推送数量
        Boolean toDaySendMSG = redisTemplate.delete("toDaySendMSG");
        logger.info("每日清空消息推送次数结果------->" + toDaySendMSG);
        //清空服务器上报指标数量
        Boolean toDayServerPush = redisTemplate.delete("toDayServerPush");
        logger.info("每日清空服务器指标推送次数结果------->" + toDayServerPush);
        //清空过滤无用信息的数量
        Boolean toDayMeaningless = redisTemplate.delete("toDayMeaningless");
        logger.info("每日清空过滤无用推送次数结果------->" + toDayMeaningless);
        //清空统计自动重启服务的数量
        Boolean toDayServiceRestart = redisTemplate.delete("toDayServiceRestart");
        logger.info("每日清空重启服务推送次数结果------->" + toDayServiceRestart);
        //清空统计成功防止数据库死锁的数量
        Boolean toDayKillDataBase = redisTemplate.delete("toDayKillDataBase");
        logger.info("每日清空防止数据库死锁次数结果------->" + toDayKillDataBase);
    }
}
